package diko_parent.eduservice.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.diko.commonUtils.R;
import diko_parent.eduservice.entity.EduCourse;
import diko_parent.eduservice.entity.frontVo.CourseQueryVo;
import diko_parent.eduservice.service.EduCourseService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Emma Li
 * @date 2020/10/22 - 10:31
 */
//@CrossOrigin
@RestController
@RequestMapping("/eduservice/frontcourse")
public class CourseFrontController {

    @Autowired
    private EduCourseService courseService;

    @ApiOperation(value = "分页课程列表")
    @PostMapping(value = "{page}/{limit}")
    public R pageList(
            @ApiParam(name="page",value = "当前页码",required = true)
            @PathVariable Long page,

            @ApiParam(name="limit",value = "每页记录数",required = true)
            @PathVariable Long limit,

            @ApiParam(name="courseQuery",value = "查询对象",required = false)
            @RequestBody(required = false)CourseQueryVo courseQueryVo
            ){
        Page<EduCourse> pageParam = new Page<>(page, limit);
        Map<String, Object> map = courseService.pageListWeb(pageParam, courseQueryVo);
        return R.ok().data(map);
    }

}
